<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/jobseeker/tmpl/candidateprofile.php
 ^ 
 * Description: template view for control panel
 ^ 
 * History:		NONE
 ^ 
 */
  defined('_JEXEC') or die('Restricted access');
  global $mainframe;
  $document =& JFactory::getDocument();

  $document->addScript( 'components/com_wrecruit/js/jquery-1.7.2.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery-ui.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery.uniform.js' );
  $document->addScript( 'components/com_wrecruit/js/scripts.js' );
  $document->addScript( 'components/com_wrecruit/js/popup.js' );
  $document->addStyleSheet('components/com_wrecruit/css/popup.css');
  
  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
  $user	=& JFactory::getUser();
  if(isset($user->id) && $user->id == 0 || $user->id == ''){
	   $app =& JFactory::getApplication(); 
	   $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );
	  return;
  }else{
  	$candidateObj = $candidate->getAllCandidatesInfor($user->id);
	if( !$candidateObj ){
		$app =& JFactory::getApplication(); 
       //add a message to the message queue
        $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );

		return;
	}
	
   }
    ?>
    <?php 
	 $js_uniform = '<script>
          jQuery(document).ready(function(){
				jQuery("select.dropdown-box, select, input[type=\'checkbox\'], input[type=\'radio\'], input[type=\'file\'],input[type=\'text\']").uniform({useID: true,idPrefix: \'container-drop-bo\'});
				
				jQuery("ul.dropdown > li").mouseover(function(e){
					console.log(jQuery(this).width());
				});
				jQuery("ul.dropdown ul li, ul.dropdown ul").mouseover(function(e){
					return false;
				});
				
			
	
          });
		</script>';
		
	$form = JRequest :: getVar('form');
    //FormEdite Mail
	if( $form == 'emailform'){
	?>
         <a id="close" class="hidden" title="close popup"></a>   
                    <center>
         <?php 
		 
		 ?>
        <form action="index.php" method="post" id="frm_change_mail">
        
        <div class="pop-content1" style="width:530px;">
            <div class="head-title" id="pop-head">
                <h2>Change Email</h2>
            </div>
          <div class="pop"><label class="pop-label-email">Your new E-mail address:</label>
            <input type="text" id='new_mail' class="text-email" name="new_mail" placeholder="Your new E-mail address..." />
          </div>
           <div class="pop"><label class="pop-label-email">Confirm your new E-mail address:</label>
            <input type="text" id='com_firm_mail' class="text-email" name="confirm_new_mail" placeholder="Confirm your new E-mail address..." />
          </div>
          <div class="pop" id="note"><strong>Note: </strong>after this change, later on you will log in with this new email address and all notifications by Email will be also sent to this mail address.</div>
    
            
         <div class="btn-action">
            <div class="wrapp-btn">
                <span class="btn-left"><span class="btn-right"><input type="submit" value="Save" class="btn" id="save-email" /> &nbsp;</span></span>
           </div>
         </div>
            <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="id">
            <input type="hidden" value="candidatepanel" name="layout">
            <input type="hidden" value="com_wrecruit" name="option">
            <input type="hidden" value="changeMail" name="task">
             
        </div>
        
        </form>
		<script>
			jQuery(function(){
			  jQuery("#save-email").click(function(e){
					e.preventDefault();
					var nm = jQuery("#new_mail").val();
					var cm = jQuery("#com_firm_mail").val();
					if( nm == ''){
							alert("Please provide new mail!");
							return;
					}
					if( cm == ''){
							alert("Please provide confirm mail!");
							return;
					}
					if(!isValidEmailAddress(nm)){
							alert("Your new mail is not correct mail formart!");
							return;
					}
					if(!isValidEmailAddress(cm)){
							alert("Your confirm mail is not correct mail formart!");
							return;
					}
					jQuery("#frm_change_mail").submit();
			  });
			  function isValidEmailAddress(emailAddress) {
				var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
				return pattern.test(emailAddress);
			  };

				
			
			});
		</script>
        <?php 
         echo $js_uniform;
        ?>
        </center>
	<?php 
    } 
    //End FormEdite Mail
	?>
	
    <?php 
    //FormEdite Password
	if( $form == 'passwordform'){
	?>
    	<?php 
		 $user	=& JFactory::getUser();
		// print_r($candidateObj);
		?>
         <a id="close" class="hidden" title="close popup"></a>   
                    <center>
                 <form action="index.php" method="post" id="frm_change_password"> 
                    <div class="pop-content1" id="wrapp-change-password">
                      <div class="head-title" id="pop-head">
                            <h2>Change Password</h2>
                      </div>
                      <div class="pop"><label class="pop-label-email">Your current password:</label>
                        <input type="password" class="text-email" id="current_password"  value="" name="current_password" placeholder="Your current password..." />
                        <span class="star1">&nbsp;</span>
                      </div>
                       <div class="pop"><label class="pop-label-email">Your new password:</label>
                        <input type="password" class="text-email"  id="new_password" value="" name="new_password" placeholder="Your new password..." />
                        <span class="star1">&nbsp;</span>
                      </div>
                       <div class="pop"><label class="pop-label-email">Confirm your new password:</label>
                        <input type="password" class="text-email" id="confirm_new_password" value="" name="confirm_new_password" placeholder="Confirm your new password..." />
                        <span class="star1">&nbsp;</span>
                      </div>
                        
                      <div class="btn-action">
                        <div class="wrapp-btn">
                            <span class="btn-left"><span class="btn-right"><input type="submit" value="Save" class="btn" id="save-password" /> &nbsp;</span></span>
                       </div>
                     </div>
                        
                    </div>
                    
                    <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="id">
                    <input type="hidden" value="candidatepanel" name="layout">
                    <input type="hidden" value="com_wrecruit" name="option">
                    <input type="hidden" value="changePassword" name="task">
        </form>
		<script>
			jQuery(function(){
			  jQuery("#save-password").click(function(e){
					e.preventDefault();
					var cp = jQuery("#current_password").val();
					var np = jQuery("#new_password").val();
					var conp = jQuery("#confirm_new_password").val();
					if( cp == ''){
							alert("Please provide you current password!");
							return;
					}
					if( np == ''){
							alert("Please provide your new password!");
							return;
					}
					if( conp == ''){
							alert("Please provide confirm password!");
							return;
					}
					if( conp != np){
							alert("New password and confirm new password not match!");
							return;
					}
					jQuery("#frm_change_password").submit();
			  });
			});
		</script>
         <?php 
         echo $js_uniform;
        ?>
        </center>
	<?php 
    } 
    //End FormEdite password
	?>
	
    <?php 
    //Post post-cv-leading-page
	if( $form == 'post_cv_leading_page' || $form == 'edit_post_cv_leading_page'){
	?>
    	<?php  
		  $user	=& JFactory::getUser();
		  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
		?>
	<?php
		if( $form == 'post_cv_leading_page' || $form == 'edit_post_cv_leading_page'){
			if( $form == 'post_cv_leading_page'){
				$cv_title = '';
				$industry = $candidate->getIndustries('industry[]',' data-placeholder="Choose any industries (4 max)..." multiple="8" class="chzn-select" style=" float: left; margin-bottom:3px; width: 346px; border: 1px solid #e8e8e8;"');;
				$salary = $candidate->getSalary();
				$preference = $candidate->getPreference();
				$edu_level = $candidate->getEduLevel();
				$year_of_experiance = '';
				$method = 'add';
				
			} else if($form == 'edit_post_cv_leading_page') {
			    $cv_info = $candidate->getCvInfoById(JRequest::getVar('row_id'));
				
			    $cv_title = '';
				$industry = $candidate->getIndustries('industry[]',' data-placeholder="Choose any industries (4 max)..." multiple="8" class="chzn-select" style=" float: left; margin-bottom:3px; width: 346px; border: 1px solid #e8e8e8;"');
				$salary = $candidate->getSalary();
				$preference = $candidate->getPreference();
				$edu_level = $candidate->getEduLevel();
				$year_of_experiance = '';
				$method = 'add';
			}
		}
	?>
    <a id="close" class="hidden" title="close popup"></a>   
    <center>
    <form action="index.php" method="post" id="frm_post_leading_cv">        
        <div class="pop-content1" id="wrapp-post-cv">
            <div class="head-title" id="pop-head">
                <h2>Post CV</h2>
            </div>
          <div class="pop"><label class="pop-label-post-cv">CV Title:</label>
            <input type="text" class="text-post-cv" name="cv_title" id="cv_title" value="<?php echo $cv_title; ?>" placeholder="CV Title..." />
            <span class="star1">*</span>
          </div>
           <div class="pop"><label class="pop-label-post-cv">Industry:</label>
            <?php
              echo $industry;
            ?>
			<script src="components/com_wrecruit/js/chosen/chosen.jquery.js" type="text/javascript"></script>
				<script type="text/javascript"> 
					jQuery(".chzn-select").chosen();
					jQuery(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
					
				</script>
            <span class="star1">*</span>
          </div>
           
           <div class="pop"><label class="pop-label-post-cv">Salary:</label>
             <?php 
			   echo $salary;
			 ?>
            <span class="star1">&nbsp;</span>
          </div>
           <div class="pop"><label class="pop-label-post-cv">Work preference:</label>
             <?php echo $preference; ?>
            <span class="star1">*</span>
          </div>
          <div class="pop"><label class="pop-label-post-cv">Education Level:</label>
            <?php echo $edu_level; ?>
            <span class="star1">&nbsp;</span>
          </div>
           <div class="pop"><label class="pop-label-post-cv">Years of experience:</label>
            <input type="text" class="text-post-cv"  id="year_of_experiance" name="year_of_experiance" value="<?php echo $year_of_experiance; ?>" placeholder="Years of experience..." />
            <span class="star1">*</span>
          </div>
          
          <div class="pop" id="check-post-cv"> 
            <input type="checkbox"  class="available"  name="available" id="check-ava-post-cv" />Available?
            <input type="checkbox"  class="searchable" name="searchable" id="check-sea-post-cv" />Searchable?
          </div>
          
          <div class="" style="text-align:left;">Choose how you want to create your CV</div>
          <div style="overflow: hidden;">
              <ul id="choose-cv">
                <li><input type="radio" name="buil_cv_type"  id="radio-post-cv" value="our_tool" checked="checked" /><a id="link_bc" href="#" title="">Build your CV</a> with our tool</li>
                <li><input type="radio" name="buil_cv_type"  id="radio-upload-cv" value="your_own_file"/> <a id="link_upl" href="#" title="">Upload or copy and paste your CV</a></li>
              </ul>
              <div class="btn-action">
                <div class="wrapp-btn">
                    <span class="btn-left"><span class="btn-right"><input type="submit" value="Next" class="btn" id="next-post-cv" /> &nbsp;</span></span>
               </div>
             </div>
          
          </div>   
        </div>      
                        <input type="hidden" value="" name="id">
                        <input type="hidden" value="cvuploadcopyandpast" name="layout">
                        <input type="hidden" value="com_wrecruit" name="option">
                        <input type="hidden" value="cv_upload_copy_paste" name="task">
                        <input type="hidden" value="candidates" name="view" />
						<input type="hidden" value ="<?php echo $method;?>" name="method" />
                        <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
                        <div style="display:none">
                            <?php echo $candidateObj->country;?>
                        </div>
                        
                        
                        
            </form>
             <?php 
             echo $js_uniform;
             ?>
            </center>
			<script>
			jQuery(function(){
			  jQuery("#next-post-cv, #link_bc, #link_upl").click(function(e){
					e.preventDefault();
					var ct = jQuery("#cv_title").val();
					var ind = jQuery("#industry").val();
					var wr = jQuery("#work-reference").val();
					var we = jQuery('#year_of_experiance').val();
					if( ct == ''){
							alert("Please provide cv title!");
							return;
					}
					if( ind == '' || !ind ){
							alert("Please chose at less one of industry!");
							return;
					}
					if( wr == ''){
							alert("Please chose at less one of reference!");
							return;
					}
					if( we == ''){
							alert("Please provide year of experiance!");
							return;
					}
					jQuery("#frm_post_leading_cv").submit();
			  });
			});
		</script>
        <?php 
        } 
        //End Post Leading cv
        ?>
       
	   <?php
        //professional form experience
        if($form=="proexperienceform" || $form =="editproexperienceform"){
				$employer_name = '';
				$employer_position = '';
				$employer_resp = '';	
				$employer_start_date ='';
				$employer_leave_date = '';
				$employer_street_address = '';
				$employer_phone = '';
				$employer_city = '';
				$ch1 = '';
			    $ch2 = 'checked="checked"';
				$employer_countryDropDownlist = $candidate->getCountryDropDownlistByName('adfdaf','employer_country', 'class="dropdown-box text-reference text" id="country"');
				if($form =="editproexperienceform"){
					$pro_data = $candidate->getProListByProId(JRequest::getVar('row_item'));
					$employer_name = $pro_data->employer;
					$employer_position = $pro_data->employer_position;
					$employer_resp = $pro_data->employer_resp;	
					$employer_start_date = $pro_data->employer_from_date;	
					$employer_leave_date = $pro_data->employer_to_date;
					$employer_street_address = $pro_data->employer_address;
					$employer_phone = $pro_data->employer_phone;
					$employer_city = $pro_data->employer_city;
					$employer_countryDropDownlist = $candidate->getCountryDropDownlistByName($pro_data->employer_country,'employer_country', 'class="dropdown-box text-reference text" id="country"');
					
					if( $pro_data->employer_isworkhere == 0 || $pro_data->employer_isworkhere == '' ){
					  $ch2 = '';
					  if($pro_data->employer_to_date != ''){
						$ch1 = 'checked="checked"';
						$ch2 = '';
					  }
					} else if ($pro_data->employer_isworkhere == 1) {
					  $ch2 = 'checked="checked"';
					}
					
				}
				
        ?>
				<a id="close" class="hidden" title="close popup"></a>   
				<center>
				<form action="index.php" method="post" id="frm_reference">
					<div class="pop-content1" style="width:503px; margin: 10px 0 15px 25px;" id="experience">
					<div class="head-title" id="pop-head" style="margin-bottom:0px;">
						<h2>Your Work Experience</h2>
					</div>
                  	<div class="pop">                    
                    	<label class="pop-label-experience">Company Name:</label>
                    	<input type="text" class="text-experience" id="employer_name" name="employer_name" value="<?php echo $employer_name;?>" placeholder="Company Name..." />
                    	<span class="star1">*</span>
                  	</div>
                    <div class="pop">                    
                    	<label class="pop-label-experience">Worked as:</label>
                    	<input type="text" class="text-experience" id="employer_position" name="employer_position" value="<?php echo $employer_position;?>" placeholder="Function/Position" />
                    	<span class="star1">*</span>
                  	</div>
                    
                    <div style="margin: 0 13px 15px 0; float: left;">
                    	<label class="pop-label-email">Work responsibility:</label>
                  		<textarea class="textarea-experience" style="color:#000 !important;" id="wrespon"  name="employer_resp" placeholder="Work responsibility..." ><?php echo $employer_resp;?></textarea>
                  		<span class="star2">*</span>
              		</div>
                  <div class="" style="float:left; width:510px; margin: 0 13px 15px 0;">
                  	<label class="pop-label-date-ex">Start date:</label>
                   	<input type="text" class="text-re-phone" name="employer_start_date" value="<?php echo $employer_start_date; ?>" id="start_date" placeholder="Start date..." />
                    <span class="star4">*</span>
                   
                   <label class="pop-label-date-ex1">Leave date:</label>
                   <ul id="ex-date-list">
                       <li>
                        <input name="isworkhere" value="0" type="radio" <?php echo $ch1;?> id='ch1' style="float:left;">
                        <input type="text" name="employer_leave_date" value="<?php echo $employer_leave_date;?>" id="leave_date" style="float:left;" placeholder="Leave date ..." />
                        </li>
                        <li>
                        	<input name="isworkhere" value="1" <?php echo $ch2;?> type="radio" id="ch2">
                            <a href="#" style="text-decoration: underline; color: #888;">I currently work here</a>
                        </li>
                    </ul>
                  </div>
				    <?php 
					
					$styles = "
						/* located in demo.css and creates a little calendar icon
						 * instead of a text link for 
						 */
						a.dp-choose-date {
							float: left;
							width: 16px;
							height: 16px;
							padding: 0;
							margin: 5px 3px 0;
							display: block;
							text-indent: -2000px;
							overflow: hidden;
							background: url(calendar.png) no-repeat; 
						}
						a.dp-choose-date.dp-disabled {
							background-position: 0 -20px;
							cursor: default;
						}
						/* makes the input field shorter once the date picker code
						 * has run (to allow space for the calendar icon
						 */
						input.dp-applied {
							width: 140px;
							float: left;
						}
						#dp-popup{
							z-index:19999;
						}
					";
					$document->addStyleDeclaration($styles, 'text/css');
					?>
					<script type="text/javascript" src="/ga_svn/components/com_wrecruit/js/datedeclare.js"></script>
					<script type="text/javascript" src="/ga_svn/components/com_wrecruit/js/date.js"></script>
					<script>
					jQuery(function()
					{
						jQuery('#start_date').datePicker({format:'yyyy-mm-dd'});
						jQuery('#leave_date').datePicker({format:'yyyy-mm-dd'});
						jQuery('#ch2').click(function(){
							jQuery("#leave_date").val('');
						});	
						jQuery('.dp-choose-date').click(function(){
							jQuery("#ch1").attr('checked','checked');
						});	
					});
					</script>
                 <div class="pop"><label class="pop-label-email"><strong>Company Contact</strong></label></div>
                 <div class="pop"><label class="pop-label-48">Phone:</label>
                    <input type="text" class="text-167" name="employer_phone" value="<?php echo $employer_phone; ?>" placeholder="Phone number..." />
                    <span class="star4">&nbsp;</span>
                    <label class="pop-label-48">Email:</label>
                    <input type="text" class="text-189" name="ex-email" placeholder="email..." />
                    <span class="star1"></span>
                 </div>
                
                <div class="pop"><label class="pop-label-60">Address:</label>
                    <input type="text" class="text-407" name="employer_street_address" value="<?php echo $employer_street_address;?>" placeholder="Address..." />
                    <span class="star3"> &nbsp;</span>
                 </div>
            
               <div class="pop"><label class="pop-label-60">Country:</label>
                	<?php 
                        echo $employer_countryDropDownlist;
                    ?>
                	<label class="pop-label-48" style="width: 30px;">&nbsp;City:</label>
                	<input type="text" class="text-189" name="employer_city" value="<?php echo $employer_city;?>" placeholder="City..." />
                </div>
                  
				  
              <div class="btn-action">
                <div class="wrapp-btn" style="margin-left: 5px;">
                    <span class="btn-left"><span class="btn-right">
				 <?php if( JRequest::getVar('method') != "edit" ){?>
					<input type="submit"  class="btn" value="Done & One more"  id="save-one-more"/>&nbsp;</span></span>
				 <?php }?>
                </div>
                <div class="wrapp-btn">
                    <span class="btn-left"><span class="btn-right"><input type="submit"  class="btn" value="Done"  id="save-reference"/>&nbsp;</span></span>
                </div>           
             </div>
					
			</div>
					<input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="id">
					<input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="raw_id">
					<input type="hidden" value="buildcv" name="layout">
					<input type="hidden" value="com_wrecruit" name="option">
					<input type="hidden" value="addprofessionalexperience" name="task">
					<input type="hidden" value="candidates" name="view" />
					<input type="hidden" value ="<?php echo JRequest::getVar('method');?>" name="method" />
					<input type="hidden" value ="<?php echo JRequest::getVar('row_item');?>" name="row_item" />
					<input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
					</form> 
			<?php 
				 echo $js_uniform;
			?>
			<script>
			jQuery(function(){
			  jQuery("#save-reference, #save-one-more").click(function(e){
					e.preventDefault();
					var emn = jQuery("#employer_name").val();
					var emp = jQuery("#employer_position").val();
					var wrespon = jQuery("#wrespon").val();
					var s_date = jQuery('#start_date').val();
					if( ct == ''){
							alert("Please provide cv title!");
							return;
					}
					if( emn == ''){
							alert("Please provide company's name!");
							return;
					}
					if( emp == ''){
							alert("Please provide worked as!");
							return;
					} 
					if( wrespon == ''){
							alert("Please provide your responsibility!");
							return;
					}
					if( s_date == '' ){
							alert("Please provide start date!");
							return;
					}
					if(jQuery(this).val() == 'Done'){
						jQuery("#frm_reference").submit();
					};
					
					   //If click one more
						jQuery.ajax({
							url:'index.php',
							type:'POST',
							asynce:true,
							data:jQuery('#frm_reference').serialize(),
							success:function(msg){
								alert("Success saved");
								var inputs = jQuery('#frm_reference').find('input'); 
								inputs.each(function(){
								  if( jQuery(this).val() != 'Done' && jQuery(this).val() != 'Done & One more' && jQuery(this).attr('type') != 'hidden' && jQuery(this).attr('type') != 'button' && jQuery(this).attr('type') != 'submit'){
										jQuery(this).val('');
								  }
								});
								jQuery("#wrespon").val('');
							}
						});
					
					
			  });
			});
		  </script>
		</center>
    <?php
	}
	//End professional from experience
	?>
	
		
		
        <?php 
        //Form education
        if($form =="educationform" || $form == "editeducation" ){
        ?>
                <?php  
                  $user	=& JFactory::getUser();
                  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
				  
				  //Field
				  $method = '';
				  $row_item = '';
				  
				  $level = '';
			      $name = ""; //ok
				  $countryDropDownlist = $candidateObj->country; //ok
				  $certificate_name = ""; // ok
				  $certificate_year = '';
				  $study_area = ""; //ok
				  
				  if($form =="editeducation"){
						if(JRequest::getVar('row_item')){
						 $subfix = JRequest::getVar('row_item');
						}else {
						 $subfix = '';
						}
						
						$cv_data = $candidate->getCvInfoById(JRequest::getVar('row_id'));
						if($cv_data){
							$method = 'edit';
				            $row_item = JRequest::getVar('row_item');
							
							$level = $cv_data['institute'.$subfix.'_level'];
							$name = $cv_data['institute'.$subfix];
							$countryDropDownlist = $candidate->getCountryDropDownlistByName($cv_data['reference'.$subfix.'_country']);
							$certificate_name = $cv_data['institute'.$subfix.'_certificate_name'];
							$certificate_year = $cv_data['institute'.$subfix.'_cert_year'];
							$study_area = $cv_data['institute'.$subfix.'_study_area'];
						}
						
					}
                ?>
                <a id="close" class="hidden" title="close popup"></a>   
                <center>
                <form action="index.php" method="post" id="frm_education">
                <div class="pop-content1" style="width: 535px;" id='education'>
                    <div class="head-title" id="pop-head">
                        <h2>Add Education</h2>
                    </div>
                  <div class="pop"><label class="pop-label-education">Education level :</label>
                      <?php echo $candidate->getEduLevel($level); ?>
                    <span class="star4">*</span>
                  </div>
                  <div class="pop"><label class="pop-label-education">Institute name :</label>
                    <input type="text" class="text-education" name="institute_name" id = "institute_name"  value='<?php echo $name;?>' placeholder="Institute name..." />
                    <span class="star4">*</span>
                      <?php 
                        echo $candidateObj->country;
                      ?>
                     <span class="star4">&nbsp;</span>
                  </div>
                  <div class="pop"><label class="pop-label-education">Certification degree :</label>
                     <input type="text" class="text-education" id="certificate_name" name="certificate_name" placeholder="Certification degree..." value="<?php echo $certificate_name; ?>" />
                     <span class="star4">*</span>
                     <select name="certificate_year"  id="yearofdegree" class="pop-dropdown" >
                            <option value="">Year of degree...</option>
							<option value="1">1 Year</option>
							<option value="2">2 Years</option>
                     </select>
                    <span class="star1">*</span>
                  </div>
                  <div class="pop"><label class="pop-label-education">Area of study :</label>
                    <input type="text" class="text-areaofstudy" name="study_area" id="study_area" value='<?php echo $study_area;?>' placeholder="Area of study..." /> 
                    <span class="star1">*</span>
                    
                  </div>
                    
                 <div class="btn-action">
                    <div class="wrapp-btn" style="margin-left: 5px;">
                        <span class="btn-left"><span class="btn-right">
						<?php if($method !="edit"){?>
						<input type="submit" value="Done & one more" class="btn"  id="save_one_more_ed"/>&nbsp;
						<?php }?>
						
						</span></span>
                  	</div>
                    <div class="wrapp-btn">
                        <span class="btn-left"><span class="btn-right"><input type="submit" value="Done" class="btn" id="save_ed"/>&nbsp;</span></span>
                    </div>
                  </div>
                    
                </div>
                <input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="id">
                <input type="hidden" value="buildcv" name="layout">
                <input type="hidden" value="com_wrecruit" name="option">
                <input type="hidden" value="addEduCv" name="task">
                <input type="hidden" value="candidates" name="view" />
				 <input type="hidden" value="<?php echo $row_item;?>" name="row_item" />
				  <input type="hidden" value="<?php echo $method;?>" name="method" />
                <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
                </form>
                <?php 
                echo $js_uniform;
                ?> 
				<script>
			jQuery(function(){
			  jQuery("#save_ed, #save_one_more_ed").click(function(e){
					e.preventDefault();
					var edl = jQuery("#ed-level").val();
					var in_n = jQuery("#institute_name").val();
					var cn = jQuery("#certificate_name").val();
					var yd = jQuery('#yearofdegree').val();
					var sa = jQuery('#study_area').val();
					if( edl == ''){
							alert("Please provide Education level!");
							return;
					}
					if( in_n == ''){
							alert("Please provide institute's name!");
							return;
					}
					if( cn == ''){
							alert("Please provide certification degree!");
							return;
					} 
					if( yd == ''){
							alert("Please provide Year of degree!");
							return;
					}
					if( sa == '' ){
							alert("Please provide area study!");
							return;
					}
					if(jQuery(this).val() == 'Done'){
						jQuery("#frm_education").submit();
					}
					
					   //If click one more
						jQuery.ajax({
							url:'index.php',
							type:'POST',
							asynce:true,
							data:jQuery('#frm_education').serialize(),
							success:function(msg){
								alert("Success saved");
								var inputs = jQuery('#frm_education').find('input'); 
								inputs.each(function(){
								  if( jQuery(this).val() != 'Done' && jQuery(this).val() != 'Done & One more' && jQuery(this).attr('type') != 'hidden' && jQuery(this).attr('type') != 'button' && jQuery(this).attr('type') != 'submit'){
										jQuery(this).val('');
								  }
								});
							}
						});
					
					
			  });
			});
		  </script>
			</center>
                </center>
                 
            
        <?php
        }
        //End form eduction
        ?>
        
        
    
    <?php 
	//Skill form
	if( $form == "skillform" || $form == "editskillform" ){
	?>
    <a id="close" class="hidden" title="close popup"></a>   
        <center>
            <form action="index.php" method="post" id="frm_skill">
            <div class="pop-content1" style="width: 500px;">
                <div class="head-title" id="pop-head">
                    <h2>Your Skills</h2>
                </div>
              <div class="pop" style ="margin:0px;"><label class="pop-label" style="width:30px;">Skills:</label>
                
                <?php 
				    $row_item_id = '';
					if(JRequest::getVar('row_item') != '' && $form == "editskillform" ){
						$strid = explode('and',JRequest::getVar('row_item'));
						$row_item = $strid[0];
						$row_item_id = $strid[1];
						echo $candidate->getSkillList('Add any skill now...', $row_item );
					}else{
						//echo $candidate->getSkillList('Add any skill now...');
						echo $candidate->getSkillList('',false,' id="skill_item" multiple="8" class="chzn-select" style="width:385px; height:22px; border: 1px solid #e8e8e8;"','skill[]');
						
					}
					
			    ?>
				<script src="components/com_wrecruit/js/chosen/chosen.jquery.js" type="text/javascript"></script>
				<script type="text/javascript"> 
					jQuery(".chzn-select").chosen(); 
					jQuery(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
				</script>
                <span class="star4">*</span>
				
              </div>
                
             <div class="btn-action">
                <div class="wrapp-btn" style="margin-right: 8px;">
                    <span class="btn-left"><span class="btn-right"><input type="submit" value="Done" class="btn" id="save-skill"/>&nbsp;</span></span>
                </div>
            </div>
            <input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="id">
            <input type="hidden" value="buildcv" name="layout">
            <input type="hidden" value="com_wrecruit" name="option">
            <input type="hidden" value="addSkills" name="task">
            <input type="hidden" value="candidates" name="view" />
			<input type="hidden" value="
				<?php 
                    if(JRequest::getVar('method') != '' && $form == 'editskillform' ){
                            echo JRequest::getVar('method');
                    }
                ?>
			" name="method" />
            <input type="hidden" value="
				<?php 
                    if(JRequest::getVar('row_item') != '' && $form == "editskillform" ){
                            echo $row_item_id;
                    }
                ?>" name="row_item_id" />
            <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
            </form>
         <?php 
         //echo $js_uniform;
		 if(JRequest::getVar('method') != '' && $form == "editskillform" ){
                            echo $js_uniform;
                    }
         ?>
		 <script>
			jQuery(function(){
			  jQuery("#save-skill").click(function(e){
					e.preventDefault();
					var sk = jQuery("#skill").val();
					if( sk == '' || !sk ){
							alert("Please chose at less a skill!");
							return;
					}
					if(jQuery(this).val() == 'Done'){
						jQuery("#frm_skill").submit();
					};	
			  });
			});
		  </script>
         </center>
    <?php
	}
	//End Skill form
	?>
    <?php
	//Reference form
	if( $form =="reference" || $form =="editreference" ){
		$name = '';
		$phone = '';
		$relationship = '';
		$year = '';
		$address = '';
		$city = '';
		$subfix = '';
		$countryDropDownlist = $candidateObj->country;
		if($form =="editreference"){
			if(JRequest::getVar('row_item')){
			 $subfix = JRequest::getVar('row_item');
		    }
			$cv_data = $candidate->getCvInfoById(JRequest::getVar('row_id'));
			if($cv_data){
				$name = $cv_data['reference'.$subfix];
				$phone = $cv_data['reference'.$subfix.'_phone'];
				$relationship = $cv_data['reference'.$subfix.'_relation'];
				$year = $cv_data['reference'.$subfix.'_years'];
				$address = $cv_data['reference'.$subfix.'_address'];
				$countryDropDownlist = $candidate->getCountryDropDownlistByName($cv_data['reference'.$subfix.'_country']);
				$city = $cv_data['reference'.$subfix.'_city'];
			}
			
		}
	?>
	    <a id="close" class="hidden" title="close popup"></a>
         <center>
         <form action="index.php" method="post" id="frm_reference">
            <div class="pop-content1" style="width: 503px;">
                <div class="head-title" id="pop-head">
                    <h2>Your Reference</h2>
                </div>
              <div class="pop"><label class="pop-label-experience">Reference name:</label>
                <input type="text" class="text-reference" id="reference_name" name="reference_name" placeholder="Reference name..." value="<?php echo $name; ?>" />
                <span class="star4">*</span>
                <label class="pop-label-re-phone ">Phone:</label>
                <input type="text" class="text-re-phone" name="reference_phone" placeholder="Phone number..." value="<?php echo $phone; ?>" />
              </div>
               <div class="pop"><label class="pop-label-experience">Relationship:</label>
                <input type="text" class="text-reference" id="relationship" name="relationship" placeholder="Relationship ..." value="<?php echo $relationship; ?>" />
                <span class="star4">*</span>
                <label class="pop-label-year ">Year of knowing:</label>
                <input type="text" class="text-year" name="years" placeholder="" value="<?php echo $year; ?>" />
              </div>
              <div class="pop"><label class="pop-label-experience">Address:</label>
                <input type="text" class="text-address" name="address" placeholder=" Street address..." value="<?php echo $address; ?>"/>
                <span class="star4"></span>
              </div>
              <div class="pop"><label class="pop-label-experience">Country:</label>
                <?php 
					echo $countryDropDownlist;
                ?>
                <label class="pop-label-re-phone" style="width: 61px;"><span class="star4">&nbsp;</span>City:</label>
                <input type="text" class="text-re-phone" name="city" placeholder="City..." value="<?php echo $city; ?>" />
              </div>
              
             <div class="btn-action">
                <div class="wrapp-btn" style="margin-left: 5px;">
                    <span class="btn-left"><span class="btn-right">
					<?php if(JRequest::getVar('method') != 'edit'){ ?>
					<input type="submit"  class="btn" value="Done & one more"  id="save-one-more"/>&nbsp;
					<?php } ?>
					</span></span>
                </div>
                <div class="wrapp-btn">
                    <span class="btn-left"><span class="btn-right"><input type="submit"  class="btn" value="Done"  id="save-reference"/>&nbsp;</span></span>
                </div>           
             </div>
                
            </div>
            <input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="id">
            <input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="raw_id">
            <input type="hidden" value="buildcv" name="layout">
            <input type="hidden" value="com_wrecruit" name="option">
            <input type="hidden" value="addReferenceCv" name="task">
            <input type="hidden" value="candidates" name="view" />
            <input type="hidden" value ="<?php echo JRequest::getVar('method');?>" name="method" />
			<input type="hidden" value ="<?php echo JRequest::getVar('row_item');?>" name="row_item" />
            <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
            </form> 
            <?php
 				echo $js_uniform;
		    ?>
			<script>
			jQuery(function(){
			  jQuery("#save-reference, #save-one-more").click(function(e){
					e.preventDefault();
					var rm = jQuery("#reference_name").val();
					var rl = jQuery("#relationship").val();
					if( rm == ''){
							alert("Please provide reference name!");
							return;
					}
					if( rl == ''){
							alert("Please provide relationship!");
							return;
					}
					
					if(jQuery(this).val() == 'Done'){
						jQuery("#frm_reference").submit();
					}
					
					   //If click one more
						jQuery.ajax({
							url:'index.php',
							type:'POST',
							asynce:true,
							data:jQuery('#frm_reference').serialize(),
							success:function(msg){
								alert("Success saved");
								var inputs = jQuery('#frm_reference').find('input'); 
								inputs.each(function(){
								  if( jQuery(this).val() != 'Done' && jQuery(this).val() != 'Done & One more' && jQuery(this).attr('type') != 'hidden' && jQuery(this).attr('type') != 'button' && jQuery(this).attr('type') != 'submit'){
										jQuery(this).val('');
								  }
								});
							}
						});
					
					
			  });
			});
		  </script>
        </center>
        
    <?php
	} 
	//End Reference
	?>
    
     <?php 
    //Remove form
	if( $form == 'removeCvForm'){
	?>
	<form action="index.php" method="POST">
         <a id="close" class="hidden" title="close popup"></a>   
            <center>
       
          	<div class="pop-content1" id="wrapp-upgrade-account">
                <div class="pop" style="height:100%;margin-bottom: 5px;">
					<?php 
						$testjson = $_REQUEST['other'];
						$json = json_decode(str_replace('\\','',$testjson), true);
						
						$descript = '';
						if(isset($json) && $json['description'] ){
							$descript = $json['description'];
						}
						//print_r($json);
					?>
                    <label class="pop-label-comment-comfirm"><span id="upgrade-account">Are you sure to remove <?php echo $descript;?>?</span></label>
                   
                     <div class="btn-action">
                        <div class="wrapp-btn" style="margin-left: 5px;">
                            <span class="btn-left"><span class="btn-right"><input type="submit" class="add btn" value="Yes" border="none" />&nbsp;</span></span>
                        </div> 
                    
                        <div class="wrapp-btn" style="margin-left: 5px;">
                            <span class="btn-left"><span class="btn-right">&nbsp;&nbsp;<input type="button" class="add btn" value="Cancel" border="none" /></span></span>
                        </div> 
                     </div>   
                     <br />
                    <input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="id">
                    <input type="hidden" value="<?php echo JRequest::getVar('row_id');?>" name="raw_id">
                    <input type="hidden" value="buildcv" name="layout">
                    <input type="hidden" value="com_wrecruit" name="option">
                    <input type="hidden" value="<?php echo $json['removeAction'];?>" name="task">
                    <input type="hidden" value="candidates" name="view" />
                    <input type="hidden" value ="<?php echo $json['method'];?>" name="method" />
                    <input type="hidden" value ="<?php echo JRequest::getVar('row_item');?>" name="row_item" />
                    <input type="hidden" value="<?php echo $candidateObj->uid;?>" name="uid">
                    </form> 
                </div>
            </div>
                 
            </center>
	 </form>
	<?php 
    } 
    //End Remove form
	?>
    
    <?php 
    //No form
	if( $form == 'formwarning' || $form == 'undifiedform'){
	?>
         <a id="close" class="hidden" title="close popup"></a>   
            <center>
       
          	<div class="pop-content1" id="wrapp-upgrade-account">
                <div class="pop">
                    <label class="pop-label-comment-comfirm"><span id="upgrade-account">Sorry We could not complete your request!</span></label>
                </div>
            </div>
                 
            </center>
	<?php 
    } 
    //End Noform
	?>